/*
 * MockMediaSource.h
 *
 *  Created on: 2020年8月4日
 *      Author: chuan
 */

#ifndef MOCKMEDIASOURCE_H_
#define MOCKMEDIASOURCE_H_

#include "UMediaSource.h"
#include "UMediaSourceT.h"
#include "TThread.h"
#include <mutex>


class MockMediaSource : public UMediaSourceT< UMediaSource >, protected comn::Thread
{
public:
    MockMediaSource()
    {
    }

    ~MockMediaSource()
    {
        close();
    }

    virtual int open(const char* url, const char* params)
    {
        if (isRunning())
        {
            return 0;
        }

        start();

        return 0;
    }

    virtual void close()
    {
        stop();
    }

    virtual bool isOpen()
    {
        return isRunning();
    }


protected:
    virtual int run()
    {
        while (!m_canExit)
        {

        }
        return 0;
    }

    virtual void doStop()
    {

    }

    virtual bool startup()
    {
        return true;
    }

protected:
    std::timed_mutex    m_mutex;

};


#endif /* MOCKMEDIASOURCE_H_ */
